package com.tyd.cams.Adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import com.tyd.cams.guide.GuideBFragment;
import com.tyd.cams.guide.GuideAFragment;
import com.tyd.cams.guide.GuideCFragment;

import java.util.ArrayList;

/**
 * @author: TYD
 * @作者: 唐YaDong
 * @date: 2021/3/2
 * @时间：2021-3-2$ 13:56$
 * @description：FragmentPAdapter
 * @描述：FragmentPAdapter
 * @版本：1.0
 */
public class FragmentPAdapter extends FragmentPagerAdapter {
    ArrayList<Fragment> fragments = new ArrayList<>();
    ArrayList<String> strings = new ArrayList<>();

    public FragmentPAdapter(@NonNull FragmentManager fm) {
        super(fm);
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        switch (position) {
            case 0:
                return new GuideAFragment();
            case 1:
                return new GuideBFragment();
            case 2:
                return new GuideCFragment();
            default:
                return null;
        }
    }

    public void add(Fragment fr, String str) {
        fragments.add(fr);
        strings.add(str);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return strings.get(position);
    }
}
